package irc.controller;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;

import irc.view.*;


/**
 * This class is as of this date, not used. It should be used before we hand in the project. </br>
 * TODO: Finish this class!
 * @author ?
 * @since ?.?
 * @version ?.?
 */
public class ToolbarController {
	private ToolbarView toolbarView;
	private BaseController CC;
	private ConnectionController CnC;
	
	
	/**
	 * Constructor
	 */
	public ToolbarController(BaseController CC, ConnectionController CnC){
		toolbarView = new ToolbarView(this);
		this.CnC = CnC;
		this.CC = CC;
		CnC.getTC(this);
		giveToolbarCToCC();
	}
	

	/**
	 * ActionListeners..
	 */

	public void toolbarActionListeners(JButton connect, JButton disconnect, 
			JButton list, JButton joinChannel,  JButton colors, JButton help) {

		
		connect.addActionListener(new AbstractAction(){
			public void actionPerformed(ActionEvent ae){
	 			CnC.showFrame();
			}
		});
		
		
		disconnect.addActionListener(new AbstractAction(){
			public void actionPerformed(ActionEvent ae){
				CC.isConnected = false;
				CC.closeConnection();
			}
		});
	

		list.addActionListener(new AbstractAction(){
			public void actionPerformed(ActionEvent ae){
				CC.seeAllChannels();
			}
		});
		

		joinChannel.addActionListener(new AbstractAction(){
			public void actionPerformed(ActionEvent ae){
				String chan = JOptionPane.showInputDialog ("Channel:");
	 			if(chan != null)
	 				CC.joinChannel("#"+chan);
			}
		});
		
		colors.addActionListener(new AbstractAction(){
			public void actionPerformed(ActionEvent ae){
				CC.fc.fonts.openFontOptions();
			}
		});
		
		
		help.addActionListener(new AbstractAction(){
			public void actionPerformed(ActionEvent ae){
				CC.helpMessage();
			}
		});
	}
	
	
	/**
	 * ?
	 * @return
	 */
	public ToolbarView getToolbar(){
		return toolbarView;
	}

	
	/**
	 * ?
	 */
	public void giveToolbarCToCC(){
		CC.getToolbarC(this);
	}


	public void hideConnect() {
		toolbarView.hideConnect();
	}
	
	public void hideDisConnect() {
		toolbarView.hideDisConnect();
	}
	
}
